<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>{{ config('app.name', 'Vien Blog') }} Admin</title>
    <meta name="renderer" content="webkit">
    <!-- CSRF Token -->
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="{{asset('attach/js/css/layui.css')}}" />
    <link rel="stylesheet" href="{{asset('attach/js/wdfont/iconfont.css')}}" />
    <link rel="stylesheet" href="{{asset('attach/js/css/login.css')}}" />
</head>
<body>
<div class=" bg layadmin-user-login layadmin-user-display-show" id="LAY-user-login" style="background: url('{{asset('attach/js/images/face/timg.jpeg')}}') no-repeat;
        height:100%;
        width:100%;
        overflow: hidden;
        background-size:cover;">
    <form method="post" action=""  aria-label="{{__('登录')}}">
        @csrf
        <div class="layadmin-user-login-main drag">
            <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
                <div class="layui-form-item">
                    <label class="layadmin-user-login-icon layui-icon layui-icon-username" for="LAY-user-login-username"></label>
                    <input type="text" name="username" id="LAY-user-login-username" lay-verify="username" placeholder="{{__('用户名')}}" class="layui-input">
                </div>
                <div class="layui-form-item">
                    <label class="layadmin-user-login-icon layui-icon layui-icon-password" for="LAY-user-login-password"></label>
                    <input type="password" name="password" id="LAY-user-login-password" lay-verify="password" placeholder="{{__('密码')}}" class="layui-input">
                </div>
                <div class="layui-form-item">
                    <div class="layui-row">
                        <div class="layui-col-xs7">
                            <label class="layadmin-user-login-icon layui-icon layui-icon-vercode" for="LAY-user-login-vercode"></label>
                            <input type="text" name="vercode" id="captcha" lay-verify="vercode" placeholder="{{__('验证码')}}" class="layui-input">
                        </div>
                        <div class="layui-col-xs5">
                            <div style="margin-left: 10px;">
                                <img class="thumbnail captcha" src="{{ captcha_src('flat') }}" onclick="this.src='/captcha/flat?'+Math.random()" title="点击图片重新获取验证码">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <button class="layui-btn layui-btn-fluid" lay-submit="" lay-filter="LAY-user-login-submit">{{trans('auth.login')}}</button>
                </div>
            </div>
        </div>
    </form>
</div>
<script src="{{asset('attach/js/layui.all.js')}}"></script>
<script>
    layui.use(['form'],function () {
        var form=layui.form;
        form.verify({
            username:function (username) {
                if(username==''){
                    return "{{trans('auth.usernameTip')}}";
                }
            },
            password:function (password) {
                if(password==''){
                    return "{{trans('auth.passwordTip')}}";
                }
            },
            vercode:function (vercode) {
                if(vercode==''){
                    return "{{trans('auth.vercodeTip')}}";
                }
            }
        });
        form.on('submit(LAY-user-login-submit)',function (data) {
            var url='{{route('login')}}'
            data={username:$("#username").val(),password:$("#password").val()};
            $.ajax({
                type: 'POST',
                url: url,
                data:data,
                success: function (data) {
                    //localStorage.setItem("login",true);
                    location.href='/admin'
                },
                error: function (data) {
                    var error_msg=JSON.parse(data.responseText).errors;
                    layer.msg(error_msg.username[0],function(){
                        // location.href='/index.html'
                    });
                },
            })
            // $.post(url,data,function (res) {
            //     if(res.res='success'){
            //         console.log("sdfsdf");
            //     }else{
            //
            //     }
            // },'json');
            return false;
        })
    });
</script>
</body>
</html>